package com.xiaolun.prototype;

import java.util.Date;

/**
* 视频的原型
 * 无良up主，克隆别人的视频。
 * 1. 实现一个接口
 * 2. 重写一个方法clone()
 */
public class Video implements Cloneable{
    private String name; //视频名字
    private Date createTime; //创建日期

    public Video() {
    }

    public Video(String name, Date createTime) {
        this.name = name;
        this.createTime = createTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "Visio{" +
                "name='" + name + '\'' +
                ", createTime=" + createTime +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Object obj = super.clone();
        //需要将这个对象的属性也进行克隆，然后将新属性赋值给新的对象。
        Video v = (Video)obj;
        v.createTime = (Date) this.createTime.clone();
        return obj;
    }
}
